var MapObjects = Class.extend({
	init: function(id, config){
		this.id = id;
		this.x = config.x;
		this.y = config.y;
		this.h = mapObjectsSpecs[config.type].height;
		this.w = mapObjectsSpecs[config.type].width;
		this.sx = mapObjectsSpecs[config.type].sx;
		this.sy = mapObjectsSpecs[config.type].sy;
		this.sprite = sprites.mapObjects;
		this.depth = mapObjectsSpecs[config.type].depth;
		
		//collision coordinates
		this.cx = this.x + mapObjectsSpecs[config.type].collisionCorection[0];
		this.cy = this.y + mapObjectsSpecs[config.type].collisionCorection[1];
		this.cr = this.cx + mapObjectsSpecs[config.type].collisionCorection[2];
		this.cb = this.cy + mapObjectsSpecs[config.type].collisionCorection[3];
	},
	draw : function (canvas){
		canvas.ctx.drawImage(this.sprite.image, this.sx, this.sy, this.w, this.h, this.x, this.y, this.w, this.h);
	},
	
	isOnForeground: function (obj){
		//проверява дали този обект(this) е на преден план спряма подадения обект (obj)
		if(this.y + this.h + this.depth > obj.y + obj.h){
			return true;
		}
		return false;
	},
	kill: function (container){
		delete container[this.id];
	}
});